import json
import urllib2


def http_anonymous_get(url):
    req = urllib2.Request(url)
    res_data = urllib2.urlopen(req)
    return res_data.read()


testUrl = "http://mockbin.org/request"

result = http_anonymous_get(testUrl)

resultJson = json.loads(result)

if resultJson.has_key('startedDateTime'):  # hsa_key is deprecated
    print(resultJson['startedDateTime'])

if resultJson.has_key('headers'):
    print(resultJson['headers']['x-forwarded-for'])


if 'x-forwarded-for' in resultJson['headers']:
    print("ok")

